package com.example.jjwtlesson02.exception;

import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: anlu
 * @Date: 2021/08/12
 * @Description:
 */
@RestControllerAdvice
public class GlobleException {
    @ExceptionHandler(value = Exception.class)
    public Map defaultErrorHandler(HttpServletRequest request, Exception e)throws Exception{

       Map map = new HashMap();
       map.put("code",1000);
       map.put("msg",e.getMessage());
       map.put("data",null);
       return map;
    }

}
